﻿@*@model IEnumerable<RMS.Manage.Web.Models.Demo.Navbar>*@
@using RMS.EF.Model
@model List<RMS_Menu>
@{ 
    var userInfo = ViewBag.UserInfo as RMS_User;
}
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        @Html.ActionLink("权限管理系统", "Index", new { controller = "Default" }, new { area = "Index", @class = "navbar-brand" })
    </div>
    <!-- /.navbar-header -->
    <ul class="nav navbar-top-links navbar-right">
        <!-- /.dropdown -->
        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <i class="fa fa-user fa-fw"></i>@userInfo.NickName <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu dropdown-user">
                <li>
                    <a href="javascript:void(0);" onclick="editPwd()"><i class="fa fa-unlock-alt fa-fw"></i>修改密码</a>
                </li>
                @*<li>
                    <a href="#"><i class="fa fa-gear fa-fw"></i> Settings</a>
                </li>*@
                <li class="divider"></li>
                <li>
                    <a href="@Url.Action("Login")"><i class="fa fa-sign-out fa-fw"></i>退出</a>
                </li>
            </ul>
            <!-- /.dropdown-user -->
        </li>
        <!-- /.dropdown -->
    </ul>
    <!-- /.navbar-top-links -->
    <div class="navbar-default sidebar" role="navigation">
        <div class="sidebar-nav navbar-collapse">
            <ul class="nav" id="side-menu">
                <!--<li class="sidebar-search">
                        <div class="input-group custom-search-form">
                            <input type="text" class="form-control" placeholder="Search...">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button">
                                    <i class="fa fa-search"></i>
                                </button>
                            </span>
                        </div>
                    </li>-->
                @foreach (var item in Model)
                {
                    if (item.ParentId == "0" && (!Model.Any(p => p.ParentId == item.Id && p.Type == (int)E_Type_Menu.Menu)))
                    {
                        <li><a href="@item.Url">@item.Name</a></li>
                    }
                    else
                    {
                        if (item.ParentId == "0")
                        {
                            <li>
                                <a href="#">@item.Name<span class="fa arrow"></span></a>
                                <ul class="nav nav-second-level">
                                    @foreach (var child in Model.Where(p => p.ParentId == item.Id))
                                    {
                                        if (string.IsNullOrEmpty(child.Url))
                                        {
                                            <li><a href="#">@child.Name</a></li>
                                        }
                                        else
                                        {
                                            <li><a href="@Url.Content("~" + child.Url)">@child.Name</a></li>
                                        }
                                    }
                                </ul>
                            </li>
                        }
                    }
                }
            </ul>
        </div>
        <!-- /.sidebar-collapse -->
    </div>
    <!-- /.navbar-static-side -->
</nav>
    <script>
        var editpwdurl = "@Url.Action("EditPassword")";
        var loginurl = "@Url.Action("Login")";
        function editPwd() {
            $.modalBox("修改密码", { url: editpwdurl, search: function () { window.location.href = loginurl; } });
        }
    </script>
@section scripts{
}